package com.wxapp.common.core.mybatis;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill;
import com.wxapp.common.constant.enums.SqlMethodEnum;
import com.wxapp.common.core.mybatis.mysql.*;
import org.springframework.beans.factory.annotation.Configurable;

import java.util.List;

/**
 * @author lgl
 * @Description
 * @Datetime 2022/4/25 15:17
 * @Modified By
 */
@Configurable
public class CustomSqlInjector extends DefaultSqlInjector {

    @Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
        var methodList = super.getMethodList(mapperClass, tableInfo);
        methodList.add(new BatchSaveOrUpdate(SqlMethodEnum.BATCH_SAVE_UPDATE));
        methodList.add(new BatchUpdate(SqlMethodEnum.BATCH_UPDATE));
        methodList.add(new InsertBatch(SqlMethodEnum.INSERT_BATCH));
        methodList.add(new selectFirst(SqlMethodEnum.SELECT_FIRST));
        methodList.add(new IsExist(SqlMethodEnum.IS_EXIST));
        return methodList;
    }
}
